package com.songchaojie.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.songchaojie.dao.GoodsDao;
import com.songchaojie.entity.Category;
import com.songchaojie.entity.Goods;
import com.songchaojie.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    GoodsDao goodsDao;

    @Override
    public PageInfo<Goods> list(Goods goods, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Goods> list = goodsDao.list(goods);
        return new PageInfo<>(list);
    }

    @Override
    public List<Category> listCate() {
        return goodsDao.listCate();
    }

    @Override
    public Integer add(Goods goods) {
        return goodsDao.add(goods);
    }

    @Override
    public Goods GetById(Integer id) {
        return goodsDao.GetById(id);
    }

    @Override
    public Integer update(Goods goods) {
        return goodsDao.update(goods);
    }

    @Override
    public Integer del(Integer id) {
        return goodsDao.del(id);
    }
}
